package com.xdb.sqlparser.dialect.mysql.ast.statement;

import java.util.List;

import com.xdb.sqlparser.ast.SQLCommentHint;
import com.xdb.sqlparser.ast.SQLName;
import com.xdb.sqlparser.ast.expr.SQLIdentifierExpr;
import com.xdb.sqlparser.ast.expr.SQLPropertyExpr;
import com.xdb.sqlparser.dialect.mysql.visitor.MySqlASTVisitor;

public class MySqlShowIndexesStatement extends MySqlStatementImpl implements MySqlShowStatement {

	private SQLName table;
	private SQLName database;
	private List<SQLCommentHint> hints;

	public SQLName getTable() {
		return table;
	}

	public void setTable(SQLName table) {
		if (table instanceof SQLPropertyExpr) {
			SQLPropertyExpr propExpr = (SQLPropertyExpr) table;
			this.setDatabase((SQLName) propExpr.getOwner());
			this.table = new SQLIdentifierExpr(propExpr.getName());
			return;
		}
		this.table = table;
	}

	public SQLName getDatabase() {
		return database;
	}

	public void setDatabase(SQLName database) {
		this.database = database;
	}

	public void accept0(MySqlASTVisitor visitor) {
		if (visitor.visit(this)) {
			acceptChild(visitor, table);
			acceptChild(visitor, database);
		}
		visitor.endVisit(this);
	}

	public List<SQLCommentHint> getHints() {
		return hints;
	}

	public void setHints(List<SQLCommentHint> hints) {
		this.hints = hints;
	}
}
